package dbms;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;

public class DBGeneralFunctions {

	public static HashMap<Integer, String> getClientConfigurationMap()
	{
		try {
			HashMap<Integer, String> map = new HashMap<Integer, String>();
			
			Statement st = DBConnection.getIstance().createStatement();
			ResultSet ris = st.executeQuery("SELECT parameter, value FROM " + DBTables.CONFIG + " WHERE program='CLIENT'");
			
			while(ris.next())
				map.put(ris.getInt("parameter"), ris.getString("value"));
			
			return map;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}
	
	public static String returnStringFromSingleValueResultSet(ResultSet ris) throws SQLException
	{
		if(!ris.next()) return null;
		return ris.getString(1);
	}
	
}
